package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.BaseTenantConverter;
import com.aliyun.messagemgt.dto.base.BaseTenantDTO;
import com.aliyun.messagemgt.entities.BaseTenant;
import com.aliyun.messagemgt.repository.mappers.BaseTenantMapper;
import com.aliyun.messagemgt.domain.repository.IBaseTenantRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 租户表 服务实现类
 * </p>
 *
 * @author wugongzi
 * @since 2021-11-05
 */
@Service
public class BaseTenantMybatisRepository implements IBaseTenantRepository {
    @Autowired
    private BaseTenantMapper baseTenantMapper;
    @Override
    public BaseTenantDTO getByTenantCode(String tenantCode) {
        QueryWrapper<BaseTenant> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("tenant_code",tenantCode);
        BaseTenant baseTenant = baseTenantMapper.selectOne(queryWrapper);
        return BaseTenantConverter.INSTANCE.baseTenant2baseTenantDTO(baseTenant);
    }
}
